package com.xunheyun.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.xunheyun.vo.ConfigFile;
import com.xunheyun.vo.ConfigService;
import com.xunheyun.vo.HostServer;

@Mapper
public interface ConfSyncMapper {

	@Select("select * from xhy_config_file where config_id = #{configId}")
	public ConfigFile getConfigById(@Param("configId") int configId);
	
	@Select("select * from xhy_server where server_id = #{serverId}")
	public HostServer getHostServer(@Param("serverId") int serverId);
	
	@Select("select * from xhy_config_service where user_id = #{userId}")
	public List<ConfigService> configServiceList(@Param("userId") int userId);
	
	@Insert("insert into xhy_config_service (config_service_name,user_id,config_service_time,config_service_desc) values (#{config_service_name},#{user_id},#{config_service_time},#{config_service_desc})")
	public int insertConfigService(ConfigService configService);
	
	@Delete("delete from xhy_config_service where config_service_id=#{configServiceId}")
	public int deleteConfigService(@Param("configServiceId") int configServiceId);
	
	@Select("select * from xhy_config_file where config_service_id = #{configServiceId}")
	public List<ConfigFile> configFileList(@Param("configServiceId") int configServiceId);
	
	@Insert("insert into xhy_config_file (config_name,config_content,config_service_id,file_path) values (#{config_name},#{config_content},#{config_service_id},#{file_path})")
	public int saveConfigFile(ConfigFile configFile);
	
	@Update("update xhy_config_file set config_name=#{config_name},config_content=#{config_content},file_path=#{file_path} where config_id=#{config_id}")
	public int updateConfigFile(ConfigFile configFile);
	
	@Delete("delete from xhy_config_file where config_id = #{configId}")
	public int deleteConfigFile(@Param("configId") int configId);
	
	@Select("select * from xhy_config_file where config_id = #{configId}")
	public ConfigFile getConfigFileById(@Param("configId") int configId);
	
	@Select("select * from xhy_config_service where config_service_id = #{configServiceId}")
	public ConfigService getConfigServiceById(@Param("configServiceId") int configServiceId);
	
	@Update("update xhy_config_service set config_service_name=#{config_service_name},config_service_desc=#{config_service_desc} where config_service_id=#{config_service_id}")
	public int updateConfigService(ConfigService configService);
	
}
